import json
import random

# 读取原始JSON文件
with open("../Ti_data/graph_data_new.json", 'r', encoding="utf8") as file:
    data = json.load(file)
    print(data)
    # # 遍历每个节点，在data中添加NewNode字段
    # for node in data["nodes"]:
    #     arr=['A','B','C','D']
    #     node["data"]["classification"] = arr[random.randint(0,3)]

# 输出到新的JSON文件（保留原始格式并兼容非ASCII字符）
with open("../Ti_data/graph_data_raw.json", 'w', encoding="utf8") as file:
    json.dump(data, file, ensure_ascii=False, indent=2)
with open("../Ti_data/graph_data_raw_new.json", 'w', encoding="utf8") as file:
    json.dump(data, file, ensure_ascii=False, indent=2)
with open("../Ti_data/graph_data_matrix.json", 'w', encoding="utf8") as file:
    json.dump(data, file, ensure_ascii=False, indent=2)
with open("../Ti_data/graph_data_matrix_new.json", 'w', encoding="utf8") as file:
    json.dump(data, file, ensure_ascii=False, indent=2)